﻿<!DOCTYPE html>
<html lang="en">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
	<meta http-equiv="content-type" content="text/html;charset=utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="_csrf" content="${_csrf.token}"/>
	<meta name="_csrf_header" content="${_csrf.headerName}"/>
	<title>login</title>

	<link rel="stylesheet" href="../static/css/style.css">
	<script src="../static/js/jquery.min.js"></script>
	<script src="../static/js/vector.js"></script>

</head>
<body>

<div id="container">
	<div id="output">
		<div class="containerT">
			<h1>用户登录</h1>
			<form class="form" id="entry_form"  action="/login" method="post">
				<input type="text" placeholder="用户名" id="username" name="username" value="admin">
				<input type="password" placeholder="密码" name="password" id="password">
				<button type="button" id="entry_btn">登录</button>
				<div id="prompt" class="prompt"></div>
			</form>
		</div>
	</div>
</div>

<script type="text/javascript">
	$(function(){
		var token = $("meta[name='_csrf']").attr("content");
		var header = $("meta[name='_csrf_header']").attr("content");
		Victor("container", "output");   //登录背景函数
		$("#entry_name").focus();
		$(document).keydown(function(event){
			if(event.keyCode==13){
				$("#entry_btn").click();
			}
		});
		$("#entry_btn").on("click",function () {
			$.ajax({
				url:"/login",
				type:"POST",
				data:{username:$("#username").val(),password:$("#password").val()},
				xhrFields:{
					withCredentials : true},
				crossDomain: true,
				beforeSend:function(request){
					request.setRequestHeader(header,token)
				},
				success:function (data) {
					console.log("login")
				}});
		});
	})

</script>
</body>
</html>